package top.itaso.app.room.repository;

import androidx.lifecycle.LiveData;

import java.util.List;

import top.itaso.app.room.AppDatabase;
import top.itaso.app.room.dao.WifiScanResultDao;
import top.itaso.app.room.entity.WifiScanResultEntity;

/**
 * @Description:
 * @Author itsdf07
 * @E-Mail 923255742@qq.com
 * @Gitee https://gitee.com/itsdf07
 * @Date 2022/1/10
 */
public class WifiScanResultRepository implements IWifiScanResultRepository {
    private static WifiScanResultRepository wifiScanResultRepository;
    private WifiScanResultDao wifiScanResultDao;

    public static WifiScanResultRepository getInstance() {
        if (wifiScanResultRepository == null) {
            synchronized (WifiScanResultRepository.class) {
                if (wifiScanResultRepository == null) {
                    wifiScanResultRepository = new WifiScanResultRepository();
                }
            }
        }
        return wifiScanResultRepository;
    }

    @Override
    public LiveData<List<WifiScanResultEntity>> queryAll() {
        return wifiScanResultDao.queryAll();
    }

    @Override
    public long insertAll(WifiScanResultEntity wifiScanResultEntity) {
        return wifiScanResultDao.insertAll(wifiScanResultEntity);
    }


    @Override
    public long[] insertAll(WifiScanResultEntity... wifiScanResultEntities) {
        return wifiScanResultDao.insertAll(wifiScanResultEntities);
    }

    @Override
    public long[] insertAll(List<WifiScanResultEntity> wifiScanResultEntities) {
        return wifiScanResultDao.insertAll(wifiScanResultEntities);
    }


    @Override
    public int update(WifiScanResultEntity wifiScanResultEntity) {
        return wifiScanResultDao.update(wifiScanResultEntity);
    }

    private WifiScanResultRepository() {
        wifiScanResultDao = AppDatabase.getInstance().wifiScanResultDao();
    }
}
